package com.cct.digitalarchapi.common;

public class Response<E> {

    private String code;

    private String message;

    private E data;

    Response(String code, String message, E data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public E getData() {
        return data;
    }

    public void setData(E data) {
        this.data = data;
    }

    public static <E> Response<E> customFail(String code, String message) {
        return new Response(code, message, null);
    }

    public static <E> Response<E> bad(String message) {
        return new Response("400", message, null);
    }

    public static <E> Response<E> error(String message) {
        return new Response("500", message, null);
    }

    public static <E> Response<E> success(E data) {
        return new Response("0", "success", data);
    }
}
